import csv
from GUI_KDT.common.common_utils import CommonUtils
from GUI_KDT.config.config import keyword
import os


class Controller:

    def __init__(self):
        self.con = CommonUtils()

    def run(self):
        path = os.listdir('../data/')
        print(path)

        for i in path:
            if 'txt' in i:
                with open('../data/{}'.format(i), 'r', encoding='utf-8') as f:
                    case_data = csv.reader(f)
                    for case_list in case_data:
                        action_Ch = case_list.pop(0)  # 删掉第一个元素并且返回删掉的元素
                        action_En = keyword[action_Ch]
                        getattr(self.con, action_En)(*case_list)


if __name__ == '__main__':
    con = Controller()
    con.run()
